package com.haizhi.crm.api.controller.tag;

import com.haizhi.crm.api.constant.MediaType;
import com.haizhi.crm.common.model.Response;
import com.haizhi.crm.tag.model.TagCategoryQo;
import com.haizhi.crm.tag.service.TagCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chengmo on 2018/5/18.
 */
@Api(description = "[标签]标签分类增删改查" )
@RestController
@RequestMapping("/tag/category" )
public class TagCategoryController {

    @Autowired
    private TagCategoryService tagCategoryService;

    @ApiOperation(value = "获取所有标签分类", notes = "输入：graph" )
    @GetMapping("/findAll" )
    public Response findAll(@ModelAttribute TagCategoryQo tagCategoryQo) {
        return tagCategoryService.findAll(tagCategoryQo);
    }

    @ApiOperation(value = "保存或更新标签分类", notes = "无" )
    @PostMapping(path = "/saveOrUpdate", consumes = MediaType.APP_JSON, produces = MediaType.APP_JSON)
    public Response saveOrUpdate(@RequestBody TagCategoryQo tagCategoryQo) {
        return tagCategoryService.saveOrUpdate(tagCategoryQo);
    }

    @ApiOperation(value = "删除标签分类", notes = "已关联标签的分类无法删除" )
    @DeleteMapping(path = "/delete" )
    public Response delete(@ModelAttribute TagCategoryQo tagCategoryQo) {
        return tagCategoryService.delete(tagCategoryQo);
    }
}
